public class Cont {
public Contact contact{get; private set;}
public cont() {
Id id=ApexPages.currentPage().getParameters().get('id');
 contact=(id==null)?new contact():
[SELECT name, phone  FROM contact WHERE id=:id];
}
public PageReference save() {
try{
upsert(contact);
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
return(new Apexpages.standardController(contact)).view();
}
}